package cn.houseProperty.contoller;

import cn.entity.Do.Room;
import cn.entity.Status;
import cn.houseProperty.service.impl.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin/Room")
public class RoomContoller {
    @Autowired
    private RoomService roomService;

    @ResponseBody
    @GetMapping("/getRoomBySid")
    public Status getRoomBySid(String sid){
        Status status = new Status();
        status.setFlag(true);
        status.setData(roomService.selectBySid(sid));
        return status;
    }

    @ResponseBody
    @GetMapping("/selectAll")
    public Status selectAll(){
        Status status = new Status();
        List<Room> rooms = roomService.selectAll();
        if (rooms != null){
            status.setFlag(true);
            status.setData(rooms);
            return status;
        }else {
            status.setFlag(false);
            status.setMessage("错误");
            return status;
        }
    }
}
